import { type Ref } from 'vue'

export function isRequestSuccess(res: any): boolean {
  return res.data && res.data.code === 200 && res.data.data
}
export function onSubmit(form: Ref, cb: () => Promise<void>) {
  if (form.value) {
    form.value.validate().then(async (success: boolean) => {
      if (success) {
        await cb()
      }
    })
  }
}
